
package jz.dataCenter.fileProcess;

import org.jdom.Element;

import SFPM.sysReport.ISystemStateReport;
import SFPM.sysReport.sysStateReportManager;
import SoftFan.util.xmlHelper;

public class JzMachineDvrMgr implements ISystemStateReport {

	private static JzMachineDvrMgr	instance;

	public static JzMachineDvrMgr getInstance() {
		return instance;
	}

	private JzMachineDvrQueue	dvrQueue;

	public JzMachineDvrMgr() {
		super();
		instance = this;
	}

	public void startup() {
		dvrQueue = new JzMachineDvrQueue("DvrClip");
		dvrQueue.startup();
		sysStateReportManager.getInstance().add(this);
	}

	public void shutdown() {
		sysStateReportManager.getInstance().remove(this);
		if (dvrQueue != null) {
			try {
				dvrQueue.shutdown();
			} finally {
				dvrQueue = null;
			}
		}
	}

	public JzMachineDvrQueue getDvrQueue() {
		return dvrQueue;
	}

	public void outInfo(Element errContent, Element infoContent) {
		Element content = new Element("DvrClipMgr");
		infoContent.addContent(content);
		if (dvrQueue != null) {
			int queueSize = dvrQueue.getQueueSize();
			xmlHelper.writeTextTag(content, "DvrClipQueueSize", Integer.toString(queueSize));
		}
	}

}
